<?php

Class Detalle_report{
	private $q;
	private $res;

	public function get_detalles_report($nrodoc,$tipdoc,$fecini,$fecfin){
	if($fecini AND $fecfin)
	{
		if(date($fecini) > date($fecfin))
			{
				$cambio = $fecini;
				$fecini = $fecfin;
				$fecfin = $cambio;	
			}
		$fecfin= date("Y-m-d", strtotime("$fecfin + 1 days")); 
		$fecha = " AND (dr.fecha > '$fecini' AND dr.fecha < '$fecfin')";
		
		
	}
	else	
	
	if($fecini)
		$fecha = " AND dr.fecha > '$fecini'";
	else
	if($fecfin)
	{
		$fecfin= date("Y-m-d", strtotime("$fecfin + 1 days")); 
		$fecha = " AND dr.fecha < '$fecfin'";	
	}
	else
		$fecha = "";
	
	$this->q = "select dr.*,e.* from detalles_report dr, enfermeros e where id_report = (select id_report from reports where nro_doc_paciente = $nrodoc AND tipo_doc_paciente LIKE '$tipdoc') AND dr.id_enfermero  = e.id_enfermero".$fecha;
	$this->res = Database::query($this->q);
	return $this->res;
	}
	
	
}?>
